namespace chatroom{
    #pragma db object table("message");
    //信息存储表
    class message{
        public:
            message(){}
            message(const std::string& message_id,const boost::posix_time::ptime& created_time,const std::string& send_user_id
            ,const unsigned char message_type,const std::string& session_id)
            :_message_id(message_id),_created_time(created_time),_send_user_id(send_user_id),_message_type(message_type),_session_id(session_id){}

            std::string get_message_id()
            {
                return _message_id;
            }
            void set_message_id(std::string& val)
            {
                _message_id = val;
            }

            boost::posix_time::ptime get_created_time()
            {
                return _created_time;
            }
            void set_created_time(boost::posix_time::ptime& val)
            {
                _created_time = val;
            }

            std::string get_send_user_id()
            {
                return _send_user_id;
            }
            void set_send_user_id(std::string& val)
            {
                _send_user_id = val;
            }

            std::string get_session_id()
            {
                return _session_id;
            }
            void set_session_id(std::string& val)
            {
                _session_id = val;
            }

            unsigned char get_message_type()
            {
                return _message_type;
            }
            void set_message_type(unsigned char& val)
            {
                _message_type = val;
            }


            std::string get_content()
            {
                if(!_content)return std::string();
                return _content;
            }
            void set_content(std::string& val)
            {
                _content = val;
            }

            std::string get_file_id()
            {
                if(!_file_id)return _file_id;
                return *_file_id;
            }
            void set_file_id(std::string& val)
            {
                _file_id = val;
            }

            unsigned int get_file_size()
            {
                if(!_file_size)return 0;
                return *_file_size;
            }
            void set_file_size(unsigned int& val)
            {
                _file_size = val;
            }

            std::string get_file_name()
            {
                if(!_file_name)return std::string();
                return *_file_name;
            }
            void set_file_name(std::string& val)
            {
                _file_name = val;
            }

        private:
            friend class odb::access;
            #pragma db id auto
            unsigned long _id;
            #pragma db type("VARCHAR(64)") index unique
            std::string _message_id;
            #pragma db type("TIMESTAMP") 
            boost::posix_time::ptime _created_time;
            #pragma db type("VARCHAR(64)") 
            std::string _send_user_id;
            #pragma db type("VARCHAR(64)") index
            std::string _session_id;
            unsigned char _message_type;
            #pragma db type("VARCHAR(128)")
            odb::nullable<std::string> _content;
            #pragma db type("VARCHAR(64)")
            odb::nullable<std::string> _file_id;
            odb::nullable<unsigned int> _file_size;
            #pragma db type("VARCHAR(64)")
            odb::nullable<std::string> _file_name;    
    };
}